<?php
    $aPacketOptions = "";
    foreach ($aPacket as $key => $value) {
        $aPacketOptions .= "<option value='".$value->getId()."'>".$value->getTitle()."</option>";
    }
    $aShopOptions = "";
    foreach ($aShop as $key => $value) {
        $aShopOptions .= "<option value='".$value->getId()."'>".$value->getTitle()."</option>";
    }
?>


<div class="row">
	<div class="col-md-12 col-xs-12">
        <h1>
            <p class="pull-left">Gói sản phẩm <small>Quản lý các đăng kí mới</small></p>
            <p class="pull-right">
                <a href="<?php echo admin_page_url(PRODUCT_PACKET_SLUG); ?>" class="btn btn-default"><i class="glyphicon glyphicon-share-alt"></i> Trở về</a>
            </p>
        </h1>
    </div>
    <div class="col-md-12">
		<ol class="breadcrumb">
            <li><a href="<?php echo admin_page_url(); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li class="active"><i class="fa fa-table"></i> Danh sách đăng kí mới</li>
        </ol>
    </div>
</div>

<div class="row">
    <div class="col-md-12">
        <form id="panel-register-packet" role="form" method="POST" action="<?php echo admin_page_url(PRODUCT_PACKET_SLUG.'/dang-ki-moi/them'); ?>" data-callback='1'>
            <div class="form-group col-md-3 col-xs-12">
                <label for="packet-title">Chọn gian hàng</label>
                <select name="packet[shop_id]" class="form-control" id="packet-shop"><?php echo $aShopOptions; ?></select>
            </div>
            <div class="form-group col-md-2 col-xs-12">
                <label for="packet-product-count">Chọn gói sản phẩm</label>
                <select name="packet[packet_id]" class="form-control" id="packet-packet"><?php echo $aPacketOptions; ?></select>
            </div>
            <div class="form-group col-md-1 col-xs-12">
                <br />
                <button type="button" class="btn-submit-update btn btn-primary"><i class='glyphicon glyphicon-plus-sign'></i> Thêm</button>
            </div>
            <div class="form-group col-md-4 col-xs-12">
                <br />
                <div class="dropdown">
                    <a class="btn btn-success" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="<?php echo  admin_page_url(PRODUCT_PACKET_SLUG.'/dang-ki-moi'); ?>">
                        <i class="glyphicon glyphicon-align-justify"></i> Lọc danh sách đăng kí <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                        <li><a href="<?php echo admin_page_url(PRODUCT_PACKET_SLUG.'/dang-ki-moi', array('active'=>2)); ?>">Tất cả</a></li>
                        <li><a href="<?php echo admin_page_url(PRODUCT_PACKET_SLUG.'/dang-ki-moi', array('active'=>1)); ?>">Đã kích hoạt</a></li>
                        <li><a href="<?php echo admin_page_url(PRODUCT_PACKET_SLUG.'/dang-ki-moi', array('active'=>0)); ?>">Chưa kích hoạt</a></li>
                    </ul>
                </div>
            </div>
        </form>
    </div>
    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-bordered table-hover tablesorter item-list" id='tb-register-packet'
                data-href='<?php echo admin_page_url(PRODUCT_PACKET_SLUG.'/dang-ki-moi/cap-nhat'); ?>'
                data-accept='<?php echo admin_page_url(PRODUCT_PACKET_SLUG.'/dang-ki-moi/xac-nhan'); ?>'>
                <thead>
                    <tr>
                        <th class="header"># <i class="fa fa-sort"></i></th>
                        <th class="header">Tên <i class="fa fa-sort"></i></th>
                        <th class="header">Gói sản phẩm <i class="fa fa-sort"></i></th>
                        <th class="header">Ngày đăng kí <i class="fa fa-sort"></i></th>
                        <th class="header col-md-2">Kích hoạt</th>
                    </tr>
                    <tr class="tr-temp2 hidden">
                        <th class="header bg-info index"></th>
                        <td class="input-packet-shop"></td>
                        <td class="input-packet-packet"></td>
                        <td class="input-packet-created-at"></td>
                        <td class="input-packet-delete-flg col-md-2">
                            <input data-id="chk-del-new-" class="checkbox lb-toggle" data-name="delete_flg" type="checkbox" />
                            <label></label>
                        </td>
                    </tr>
                    <tr class="tr-temp hidden">
                        <th class="header bg-info index"></th>
                        <td class="input-packet-shop">
                            <select data-name="shop_id" class="form-control" id="t-packet-shop"><?php echo $aShopOptions; ?></select>
                        </td>
                        <td class="input-packet-packet">
                            <select data-name="packet_id" class="form-control" id="t-packet-packet"><?php echo $aPacketOptions; ?></select>
                        </td>
                        <td class="input-packet-created-at"><?php echo get_current_date(); ?></td>
                        <td class="input-packet-active-flg col-md-2">
                            <div class="btn-group">
                                <button type="button" class="btn btn-primary btn-inline-update">
                                    <i class="glyphicon glyphicon-ok-sign"></i>
                                </button>
                                <button type="button" class="btn btn-default btn-inline-close" onclick="cancelUpdate();">
                                    <i class="glyphicon glyphicon-remove-sign"></i>
                                </button>
                            </div>
                            <input type="hidden" class="input-packet-id" data-name="id" />
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($aShopPacket as $index=>$packet) { ?>
                    <tr class="can-edit" data-id="<?php echo $this->encrypt->encode($packet->getId()); ?>">
                        <th class="header bg-info index"><?php echo $index+1; ?></th>
                        <td class="input-packet-shop" data-shop-id="<?php echo $packet->getShopId(); ?>"><?php echo $packet->shop_title; ?></td>
                        <td class="input-packet-packet" data-packet-id="<?php echo $packet->getPacketId(); ?>"><?php echo $packet->packet_title; ?></td>
                        <td class="input-packet-created-at"><?php echo $packet->getCreatedAt(); ?></td>
                        <td class="input-packet-active-flg col-md-2">
                            <input id="chk-reg-<?php echo $packet->getId(); ?>"
                            	class="checkbox lb-toggle chk-register-packet-flg"
                            	data-name="active_flg"
                                <?php echo $packet->getActiveFlg()==1?'checked="checked"':''; ?>
                            	type="checkbox"/>
                            <label for="chk-reg-<?php echo $packet->getId(); ?>"></label>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
    <div class="clearfix"></div>
</div>
